package com.cmy.framework_base.basics.viewholder

import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView

/**
 * @name:
 *  BaseViewHolder
 * @package:
 *  com.cmy.framework_base.viewhodel
 * @date:
 *  2023/4/614:09
 * @author
 *    cmy
 * @description
 *
 */
open class BaseViewHolder constructor(itemView : View): RecyclerView.ViewHolder(itemView) {

    protected var context: Context

    init {
        context = itemView.context
    }

    /**
     * 绑定数据
     */
  open fun onBindData(data: IType) {}

    open fun bindDataPayload(data: IType, payloads: MutableList<Any>){}

    /**
     * ViewHodel工厂处理
     */
    interface Factory  {

        /**
         * 创建当前ViewHolder实例
         */
        fun onCreateViewHolder(holderContext: HolderContext?, parent: ViewGroup, viewType: Int): BaseViewHolder

        /**
         * 返回当前Factory对应的ItemType
         */
        fun getType(): String
    }
}

